// 新增用户
const cloud = require('wx-server-sdk');
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
exports.main = async (event, context) => {
  if (!event.openId) {
    return {
      msg: "缺少openId",
      code: 500
    }
  }
  // 往用户表新增一个用户
  const res = await db.collection('user').add({
    data: {
      openId: event.openId,
      admin: "0",
      avatar: "",
      gender: "",
      userName: "微信用户"
    }
  });
  return res;
}